import axios from "axios";
import qs from "qs";

const service = axios.create({
  // baseURL: "http://127.0.0.1:666/",
  timeout: 10000,
  // headers: { 'X-Requested-With': 'XMLHttpRequest' },
  // withCredentials: true,
});

export const postFile = (file, conf) => {
  return service({
    url: "http://127.0.0.1:666/upload/file",
    method: "post",
    data: file,
    // 上传进度事件 是一个函数
    onUploadProgress: conf,
  });
  // return axios.post("http://127.0.0.1:666/upload/file", file, conf);
};

// 合并切片接口
export const mergeFile = (file) => {
  // return axios.post(
  //   "http://127.0.0.1:666/upload/mergeUpLoadFile",
  //   qs.stringify(file)
  // );
  return service({
    url: "http://127.0.0.1:666/upload/mergeFile",
    // method: "post",
    params: file,
    // data: qs.stringify(file),
  });
};
